package com.molichuxing.services.infrastructure.convertor;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.molichuxing.services.business.dto.request.modify.StoreDeviceBizModifyDto;
import com.molichuxing.services.infrastructure.bean.*;
import com.molichuxing.services.infrastructure.dto.response.*;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;

import com.molichuxing.framework.utils.DateUtil;
import com.molichuxing.services.business.dto.request.create.DealerBizCreateDto;
import com.molichuxing.services.business.dto.request.create.StoreBizCreateDto;
import com.molichuxing.services.business.dto.request.modify.DealerBizModifyDto;
import com.molichuxing.services.business.dto.request.modify.StoreBizModifyDto;
import com.molichuxing.services.business.dto.response.DealerBizDto;
import com.molichuxing.services.business.dto.response.DealerDetailInfoBizDto;
import com.molichuxing.services.business.dto.response.DealerInfoBizDto;
import com.molichuxing.services.business.dto.response.DealerStoreBizDto;
import com.molichuxing.services.business.dto.response.DealerStoreInfoBizDto;
import com.molichuxing.services.business.dto.response.DeviceInfoBizDto;
import com.molichuxing.services.business.dto.response.StoreBaseBizDto;
import com.molichuxing.services.business.dto.response.StoreBizDto;
import com.molichuxing.services.business.dto.response.StoreInfoBizDto;
import com.molichuxing.services.infrastructure.dto.request.create.DealerCreateDto;
import com.molichuxing.services.infrastructure.dto.request.create.DealerDetailCreateDto;
import com.molichuxing.services.infrastructure.dto.request.create.DeviceCreateDto;
import com.molichuxing.services.infrastructure.dto.request.create.StoreCreateDto;
import com.molichuxing.services.infrastructure.dto.request.create.StoreDetailCreateDto;
import com.molichuxing.services.infrastructure.dto.request.modify.DealerDetailModifyDto;
import com.molichuxing.services.infrastructure.dto.request.modify.DealerModifyDto;
import com.molichuxing.services.infrastructure.dto.request.modify.DeviceModifyDto;
import com.molichuxing.services.infrastructure.dto.request.modify.StoreDetailModifyDto;
import com.molichuxing.services.infrastructure.dto.request.modify.StoreModifyDto;
import com.molichuxing.services.property.DealerStatusEnum;
import com.molichuxing.services.property.DealerTypeEnum;
import com.molichuxing.services.property.StoreIsDeliverEnum;
import com.molichuxing.services.property.StoreIsFoursEnum;
import com.molichuxing.services.property.StoreIsSaleEnum;
import com.molichuxing.services.property.StoreStatusEnum;
import com.molichuxing.services.property.StoreVerifyStatusEnum;

/**
 * @author: zph
 * @create_date: 2019年08月19日
 **/
public class Convert {


    /*********************************经销商转换开始*************************************************/

    public static List<DealerDto> toDealerDtoList(List<DealerBean> beanList) {
        List<DealerDto> dtoList = new ArrayList<>();
        if (beanList != null && beanList.size() > 0) {
            for (DealerBean dealer : beanList) {
                dtoList.add(toDealerDto(dealer));
            }
        }
        return dtoList;
    }

    public static DealerDto toDealerDto(DealerBean bean) {
        DealerDto beanDto = new DealerDto();
        if (bean != null) {
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setDealerId(bean.getId());
            Integer status = bean.getStatus();
            Integer type = bean.getType();

            if (null != status) {
                beanDto.setDealerStatusStr(DealerStatusEnum.getName(status));
            }
            if (null != type) {
                beanDto.setDealerTypeStr(DealerTypeEnum.getName(type));
            }
        }
        return beanDto;
    }

    public static List<DealerDetailDto> toDealerDetailDtoList(List<DealerDetailBean> beanList) {
        List<DealerDetailDto> dtoList = new ArrayList<>();
        if (beanList != null && beanList.size() > 0) {
            for (DealerDetailBean dealerDetail : beanList) {
                dtoList.add(toDealerDetailDto(dealerDetail));
            }
        }
        return dtoList;
    }

    public static DealerDetailDto toDealerDetailDto(DealerDetailBean bean) {
        DealerDetailDto beanDto = null;
        if (bean != null) {
            beanDto = new DealerDetailDto();
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setDealerId(bean.getId());
        }
        return beanDto;
    }

    public static Map<Integer, DealerDetailDto> toDealerDetailDtoMap(List<DealerDetailBean> dealerDetailList) {
        Map<Integer, DealerDetailDto> dealerDetailMap = new HashMap<Integer, DealerDetailDto>();
        for (DealerDetailBean dealerDetail : dealerDetailList) {
            DealerDetailDto dealerDetailBeanDto = Convert.toDealerDetailDto(dealerDetail);
            dealerDetailMap.put(dealerDetailBeanDto.getDealerId(), dealerDetailBeanDto);
        }
        return dealerDetailMap;
    }


    public static List<DealerBizDto> toDealerBizDtoList(List<DealerDto> beanList) {
        List<DealerBizDto> dtoList = new ArrayList<>();
        if (beanList != null && beanList.size() > 0) {
            for (DealerDto dealerBeanDto : beanList) {
                dtoList.add(toDealerBizDto(dealerBeanDto));
            }
        }
        return dtoList;
    }

    public static DealerBizDto toDealerBizDto(DealerDto bean) {
        DealerBizDto beanDto = new DealerBizDto();
        if (bean != null) {
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static DealerBizDto toDealerBizDto(DealerBizDto beanDto, DealerDetailDto bean) {
        if (bean != null) {
            BeanUtils.copyProperties(bean, beanDto);

        }
        return beanDto;
    }

    public static DealerBean toDealer(DealerCreateDto dealerCreateDto) {
        DealerBean dealer = new DealerBean();
        if (dealerCreateDto != null) {
            BeanUtils.copyProperties(dealerCreateDto, dealer);
        }
        return dealer;
    }

    public static DealerBean toDealer(DealerModifyDto dealerModifyDto, DealerBean dealer) {
        if (dealerModifyDto != null) {
            BeanUtils.copyProperties(dealerModifyDto, dealer);
        }
        return dealer;
    }

    public static DealerDetailBean toDealerDetail(DealerDetailCreateDto dealerDetailCreateDto) {
        DealerDetailBean dealerDetail = new DealerDetailBean();
        if (dealerDetailCreateDto != null) {
            BeanUtils.copyProperties(dealerDetailCreateDto, dealerDetail);
        }
        return dealerDetail;
    }

    public static DealerDetailBean toDealerDetail(DealerDetailModifyDto dealerDetailModifyDto, DealerDetailBean dealerDetail) {
        if (dealerDetailModifyDto != null) {
            BeanUtils.copyProperties(dealerDetailModifyDto, dealerDetail);
        }
        return dealerDetail;
    }

    public static DealerModifyDto toDealer(DealerBizModifyDto dealerBusModifyDto) {
        DealerModifyDto dealerModifyDto = new DealerModifyDto();
        if (dealerBusModifyDto != null) {
            BeanUtils.copyProperties(dealerBusModifyDto, dealerModifyDto);
        }
        return dealerModifyDto;
    }

    public static DealerDetailModifyDto toDealerDetail(DealerBizModifyDto dealerBusModifyDto) {
        DealerDetailModifyDto dealerDetailModifyDto = new DealerDetailModifyDto();
        if (dealerBusModifyDto != null) {
            BeanUtils.copyProperties(dealerBusModifyDto, dealerDetailModifyDto);
        }
        return dealerDetailModifyDto;
    }

    public static DealerCreateDto toDealer(DealerBizCreateDto dealerBusCreateDto) {
        DealerCreateDto dealerCreateDto = new DealerCreateDto();
        if (dealerBusCreateDto != null) {
            BeanUtils.copyProperties(dealerBusCreateDto, dealerCreateDto);
        }
        return dealerCreateDto;
    }

    public static DealerDetailCreateDto toDealerDetail(DealerBizCreateDto dealerBusCreateDto) {
        DealerDetailCreateDto dealerDetailCreateDto = new DealerDetailCreateDto();
        if (dealerBusCreateDto != null) {
            BeanUtils.copyProperties(dealerBusCreateDto, dealerDetailCreateDto);
        }
        return dealerDetailCreateDto;
    }

    public static DealerInfoBizDto toDealerInfoBizDto(DealerDto dealerDto) {
        DealerInfoBizDto dto = new DealerInfoBizDto();
        if (dealerDto != null) {
            BeanUtils.copyProperties(dealerDto, dto);
        }
        return dto;
    }

    public static DealerDetailInfoBizDto toDealerDetailInfoBizDto(DealerDetailDto dealerDetailDto) {
        DealerDetailInfoBizDto dto = new DealerDetailInfoBizDto();
        if (dealerDetailDto != null) {
            BeanUtils.copyProperties(dealerDetailDto, dto);
        }
        return dto;
    }

    public static Map<Integer, DealerDto> toDealerDtoMap(List<DealerBean> dealerList) {
        Map<Integer, DealerDto> dealerMap = new HashMap<Integer, DealerDto>();
        for (DealerBean dealerBean : dealerList) {
            DealerDto dealerDto = Convert.toDealerDto(dealerBean);
            dealerMap.put(dealerDto.getDealerId(), dealerDto);
        }
        return dealerMap;
    }

    public static List<DealerStoreBizDto> toDealerBizList(List<DealerDto> dealerDtoList) {
        List<DealerStoreBizDto> dtoList = new ArrayList<>();
        if (dealerDtoList != null && dealerDtoList.size() > 0) {
            for (DealerDto dealerDto : dealerDtoList) {
                dtoList.add(toDealerStoreBizDto(dealerDto));
            }
        }
        return dtoList;
    }

    public static DealerStoreBizDto toDealerStoreBizDto(DealerDto dealerDto) {
        DealerStoreBizDto dealerStoreBizDto = new DealerStoreBizDto();
        if (null == dealerDto) {
            return null;
        }

        Integer dealerId = dealerDto.getDealerId();
        if (null == dealerId) {
            return null;
        }

        dealerStoreBizDto.setId(dealerDto.getDealerId());
        dealerStoreBizDto.setName(dealerDto.getShortName());
        dealerStoreBizDto.setPId(0);

        return dealerStoreBizDto;
    }

    public static List<DealerStoreBizDto> toDealerStoreBizDtoList(List<DealerStoreBizDto> dealerBizDtoList,
                                                                  Map<Integer, List<DealerStoreBizDto>> storeMap, Boolean dealerIsShow) {
        if (null == dealerBizDtoList || dealerBizDtoList.size() <= 0) {
            return dealerBizDtoList;
        }

        if (dealerIsShow != null && !dealerIsShow) {
            return getDealerNotShowReturnList(dealerBizDtoList, storeMap);
        } else {
            return getDealerShowReturnList(dealerBizDtoList, storeMap);
        }
    }

    private static List<DealerStoreBizDto> getDealerShowReturnList(List<DealerStoreBizDto> dealerBizDtoList,
                                                                   Map<Integer, List<DealerStoreBizDto>> storeMap) {
        if (null == storeMap || storeMap.size() <= 0) {
            return dealerBizDtoList;
        }

        for (DealerStoreBizDto dealerBizDto : dealerBizDtoList) {
            Integer id = dealerBizDto.getId();
            List<DealerStoreBizDto> storeList = storeMap.get(id);
            dealerBizDto.setChilds(storeList);
        }
        return dealerBizDtoList;
    }

    private static List<DealerStoreBizDto> getDealerNotShowReturnList(List<DealerStoreBizDto> dealerBizDtoList,
                                                                      Map<Integer, List<DealerStoreBizDto>> storeMap) {
        if (null == storeMap || storeMap.size() <= 0) {
            return null;
        }

        List<DealerStoreBizDto> returnList = new ArrayList<>();
        for (DealerStoreBizDto dealerBizDto : dealerBizDtoList) {
            Integer id = dealerBizDto.getId();
            List<DealerStoreBizDto> storeList = storeMap.get(id);
            if (null == storeList || storeList.size() < 1) {
                continue;
            }

            dealerBizDto.setChilds(storeList);
            returnList.add(dealerBizDto);
        }
        return returnList;
    }

    public static Map<Integer, List<DealerStoreBizDto>> toDealerStoreBizDtoMap(List<DealerStoreBizDto> storeBizDtoList) {
        Map<Integer, List<DealerStoreBizDto>> storeMap = new HashMap<Integer, List<DealerStoreBizDto>>();
        if (null == storeBizDtoList || storeBizDtoList.size() <= 0) {
            return storeMap;
        }

        for (DealerStoreBizDto dealerStoreBizDto : storeBizDtoList) {
            if (null == dealerStoreBizDto) {
                continue;
            }

            Integer pId = dealerStoreBizDto.getPId();
            List<DealerStoreBizDto> dealerStoreBizDtoList = storeMap.get(pId);
            if (null == dealerStoreBizDtoList) {
                dealerStoreBizDtoList = new ArrayList<DealerStoreBizDto>();
            }
            dealerStoreBizDtoList.add(dealerStoreBizDto);
            storeMap.put(pId, dealerStoreBizDtoList);
        }

        return storeMap;
    }


    public static List<DealerStoreBizDto> toStoreBizList(List<StoreDto> storeDtoList) {
        List<DealerStoreBizDto> dtoList = new ArrayList<>();
        if (storeDtoList != null && storeDtoList.size() > 0) {
            for (StoreDto storeDto : storeDtoList) {
                DealerStoreBizDto storeBizDto = toDealerStoreBizDto(storeDto);
                if (null == storeBizDto) {
                    continue;
                }
                dtoList.add(storeBizDto);
            }
        }
        return dtoList;
    }

    public static DealerStoreBizDto toDealerStoreBizDto(StoreDto storeDto) {
        DealerStoreBizDto dealerStoreBizDto = new DealerStoreBizDto();
        if (null == storeDto) {
            return null;
        }

        Integer storeId = storeDto.getStoreId();
        Integer dealerId = storeDto.getDealerId();
        if (null == storeId || dealerId == null) {
            return null;
        }

        dealerStoreBizDto.setId(storeId);
        dealerStoreBizDto.setName(storeDto.getShortName());
        dealerStoreBizDto.setPId(dealerId);
        return dealerStoreBizDto;
    }


    /*********************************经销商转换结束*************************************************/


    /*********************************门店转换开始*************************************************/

    public static List<StoreDto> toStoreDtoList(List<StoreBean> beanList) {
        List<StoreDto> dtoList = new ArrayList<>();
        if (beanList != null && beanList.size() > 0) {
            for (StoreBean store : beanList) {
                dtoList.add(toStoreDto(store));
            }
        }
        return dtoList;
    }

    public static StoreDto toStoreDto(StoreBean bean) {
        StoreDto beanDto = null;
        if (bean != null) {
            beanDto = new StoreDto();
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setStoreId(bean.getId());
        }
        return beanDto;
    }

    public static List<StoreDetailDto> toStoreDetailDtoList(List<StoreDetailBean> beanList) {
        List<StoreDetailDto> dtoList = new ArrayList<>();
        if (beanList != null && beanList.size() > 0) {
            for (StoreDetailBean storeDetail : beanList) {
                dtoList.add(toStoreDetailDto(storeDetail));
            }
        }
        return dtoList;
    }

    public static StoreDetailDto toStoreDetailDto(StoreDetailBean bean) {
        StoreDetailDto beanDto = null;
        if (bean != null) {
            beanDto = new StoreDetailDto();
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setBusinessStartTime(DateUtil.formatDate(bean.getBusinessStartTime()));
            beanDto.setBusineesEndTime(DateUtil.formatDate(bean.getBusineesEndTime()));
        }
        return beanDto;
    }


    public static StoreBean toStore(StoreCreateDto storeCreateDto) {
        StoreBean bean = new StoreBean();
        if (storeCreateDto != null) {
            BeanUtils.copyProperties(storeCreateDto, bean);
        }
        return bean;
    }

    public static StoreBean toStore(StoreModifyDto storeModifyDto, StoreBean bean) {
        if (storeModifyDto != null) {
            BeanUtils.copyProperties(storeModifyDto, bean);
        }
        return bean;
    }

    public static StoreDetailBean toStoreDetail(StoreDetailCreateDto storeDetailCreateDto) {
        StoreDetailBean bean = new StoreDetailBean();
        if (storeDetailCreateDto != null) {
            BeanUtils.copyProperties(storeDetailCreateDto, bean);
        }
        return bean;
    }

    public static StoreDetailBean toStoreDetail(StoreDetailModifyDto storeDetailModifyDto, StoreDetailBean bean) {
        if (storeDetailModifyDto != null) {
            BeanUtils.copyProperties(storeDetailModifyDto, bean);
        }
        return bean;
    }

    public static Map<Integer, StoreDetailDto> toStoreDetailDtoMap(List<StoreDetailBean> storeDetailList) {
        Map<Integer, StoreDetailDto> dealerDetailMap = new HashMap<Integer, StoreDetailDto>();
        for (StoreDetailBean storeDetailBean : storeDetailList) {
            StoreDetailDto storeDetailDto = Convert.toStoreDetailDto(storeDetailBean);
            dealerDetailMap.put(storeDetailDto.getStoreId(), storeDetailDto);
        }
        return dealerDetailMap;
    }


    public static List<StoreBizDto> toStoreBizDtoList(List<StoreDto> beanList) {
        List<StoreBizDto> dtoList = new ArrayList<>();
        if (beanList != null && beanList.size() > 0) {
            for (StoreDto storeDto : beanList) {
                dtoList.add(toStoreBizDto(storeDto));
            }
        }
        return dtoList;
    }

    public static StoreBizDto toStoreBizDto(StoreDto bean) {
        StoreBizDto beanDto = new StoreBizDto();
        if (bean != null) {
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static StoreBizDto toStoreBizDto(StoreBizDto beanDto, StoreDetailDto bean) {
        if (bean != null) {
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }


    public static StoreModifyDto toStore(StoreBizModifyDto storeBizModifyDto) {
        StoreModifyDto storeModifyDto = new StoreModifyDto();
        if (storeBizModifyDto != null) {
            BeanUtils.copyProperties(storeBizModifyDto, storeModifyDto);
        }
        return storeModifyDto;
    }

    public static StoreDetailModifyDto toStoreDetail(StoreBizModifyDto storeBizModifyDto) {
        StoreDetailModifyDto storeDetailModifyDto = new StoreDetailModifyDto();
        if (storeBizModifyDto != null) {
            BeanUtils.copyProperties(storeBizModifyDto, storeDetailModifyDto);
        }
        return storeDetailModifyDto;
    }

    public static StoreCreateDto toStore(StoreBizCreateDto storeBizCreateDto) {
        StoreCreateDto storeCreateDto = new StoreCreateDto();
        if (storeBizCreateDto != null) {
            BeanUtils.copyProperties(storeBizCreateDto, storeCreateDto);
        }
        return storeCreateDto;
    }

    public static StoreDetailCreateDto toStoreDetail(StoreBizCreateDto storeBizCreateDto) {
        StoreDetailCreateDto storeDetailCreateDto = new StoreDetailCreateDto();
        if (storeBizCreateDto != null) {
            BeanUtils.copyProperties(storeBizCreateDto, storeDetailCreateDto);
        }
        return storeDetailCreateDto;
    }

    public static StoreInfoBizDto toStoreInfoBizDto(StoreDetailDto storeDetailDto, StoreInfoBizDto storeInfoBizDto) {
        if (storeDetailDto != null) {
            BeanUtils.copyProperties(storeDetailDto, storeInfoBizDto);
        }
        return storeInfoBizDto;
    }

    public static List<StoreInfoBizDto> toStoreInfoBizDtoList(List<StoreDto> beanList) {
        List<StoreInfoBizDto> dtoList = new ArrayList<>();
        if (beanList != null && beanList.size() > 0) {
            for (StoreDto storeDto : beanList) {
                dtoList.add(toStoreInfo(storeDto));
            }
        }
        return dtoList;
    }


    public static StoreInfoBizDto toStoreInfo(StoreDto storeDto) {
        StoreInfoBizDto storeInfoBizDto = null;
        if (storeDto != null) {
            storeInfoBizDto = new StoreInfoBizDto();
            BeanUtils.copyProperties(storeDto, storeInfoBizDto);
            if (storeDto.getIsFours() != null && storeDto.getIsFours()) {
                storeInfoBizDto.setIsFoursStr(StoreIsFoursEnum.YES.getName());
            } else {
                storeInfoBizDto.setIsFoursStr(StoreIsFoursEnum.NO.getName());
            }
            if (storeDto.getIsDeliver() != null && storeDto.getIsDeliver()) {
                storeInfoBizDto.setIsDeliverStr(StoreIsDeliverEnum.YES.getName());
            } else {
                storeInfoBizDto.setIsDeliverStr(StoreIsDeliverEnum.NO.getName());
            }
            if (storeDto.getIsSale() != null && storeDto.getIsSale()) {
                storeInfoBizDto.setIsSaleStr(StoreIsSaleEnum.YES.getName());
            } else {
                storeInfoBizDto.setIsSaleStr(StoreIsSaleEnum.NO.getName());
            }
            Integer status = storeDto.getStatus();
            if (status != null) {
                storeInfoBizDto.setStatusStr(StoreStatusEnum.getName(status));
            }
            storeInfoBizDto.setVerifyStatusStr(StoreVerifyStatusEnum.getName(storeDto.getVerifyStatus()));
        }
        return storeInfoBizDto;
    }

    public static StoreInfoBizDto toStoreInfo(StoreInfoBizDto storeInfoBizDto, StoreDetailDto storeDetailDto) {
        if (storeDetailDto != null) {
            BeanUtils.copyProperties(storeDetailDto, storeInfoBizDto);
        }
        return storeInfoBizDto;
    }

    public static List<DealerStoreInfoBizDto> toDealerStoreInfoBizDtoList(List<StoreDto> storeDtoList) {
        List<DealerStoreInfoBizDto> dtoList = new ArrayList<>();
        if (storeDtoList != null && storeDtoList.size() > 0) {
            for (StoreDto storeDto : storeDtoList) {
                dtoList.add(toDealerStoreInfoBizDto(storeDto));
            }
        }
        return dtoList;
    }

    public static DealerStoreInfoBizDto toDealerStoreInfoBizDto(StoreDto storeDto) {
        if (null == storeDto) {
            return null;
        }
        DealerStoreInfoBizDto dealerStoreInfoBizDto = new DealerStoreInfoBizDto();
        BeanUtils.copyProperties(storeDto, dealerStoreInfoBizDto);
        dealerStoreInfoBizDto.setStoreCode(storeDto.getCode());
        dealerStoreInfoBizDto.setStoreShortName(storeDto.getShortName());
        dealerStoreInfoBizDto.setStoreFullName(storeDto.getFullName());
        dealerStoreInfoBizDto.setStoreRegionId(storeDto.getRegionId());
        dealerStoreInfoBizDto.setStoreIsFours(storeDto.getIsFours());
        dealerStoreInfoBizDto.setStoreBrandId(storeDto.getBrandId());
        dealerStoreInfoBizDto.setStoreStatus(storeDto.getStatus());


        return dealerStoreInfoBizDto;
    }

    public static Map<Integer, DealerStoreInfoBizDto> toDealerStoreInfoBizDtoMap(List<DealerStoreInfoBizDto> dealerStoreInfoBizDtoList) {
        Map<Integer, DealerStoreInfoBizDto> dealerStoreInfoMap = new HashMap<Integer, DealerStoreInfoBizDto>();
        for (DealerStoreInfoBizDto dealerStoreInfoBizDto : dealerStoreInfoBizDtoList) {
            dealerStoreInfoMap.put(dealerStoreInfoBizDto.getStoreId(), dealerStoreInfoBizDto);
        }
        return dealerStoreInfoMap;
    }

    public static List<DealerStoreInfoBizDto> toDealerStoreInfoBizDtoList(List<DealerStoreInfoBizDto> dealerStoreInfoBizDtoList, Map<Integer, DealerDto> dealerDtoMap) {
        if (null == dealerStoreInfoBizDtoList || dealerStoreInfoBizDtoList.size() <= 0) {
            return dealerStoreInfoBizDtoList;
        }

        if (null == dealerDtoMap || dealerDtoMap.size() <= 0) {
            return dealerStoreInfoBizDtoList;
        }

        for (DealerStoreInfoBizDto dealerStoreInfoBizDto : dealerStoreInfoBizDtoList) {
            Integer dealerId = dealerStoreInfoBizDto.getDealerId();
            DealerDto dealerDto = dealerDtoMap.get(dealerId);
            toDealerStoreInfoBizDto(dealerStoreInfoBizDto, dealerDto);
        }

        return dealerStoreInfoBizDtoList;
    }

    public static DealerStoreInfoBizDto toDealerStoreInfoBizDto(DealerStoreInfoBizDto dealerStoreInfoBizDto, DealerDto dealerDto) {
        if (null == dealerStoreInfoBizDto || null == dealerDto) {
            return dealerStoreInfoBizDto;
        }

        dealerStoreInfoBizDto.setDealerId(dealerDto.getDealerId());
        dealerStoreInfoBizDto.setDealerShortName(dealerDto.getShortName());
        dealerStoreInfoBizDto.setDealerFullName(dealerDto.getFullName());
        dealerStoreInfoBizDto.setDealerType(dealerDto.getType());
        dealerStoreInfoBizDto.setDealerTypeStr(dealerDto.getDealerTypeStr());
        dealerStoreInfoBizDto.setDealerRegionId(dealerDto.getRegionId());
        dealerStoreInfoBizDto.setDealerStatus(dealerDto.getStatus());
        dealerStoreInfoBizDto.setDealerStatusStr(dealerDto.getDealerStatusStr());

        return dealerStoreInfoBizDto;
    }

    /**
     * M转为KM
     *
     * @param mm
     * @return
     */
    public static String MToKm(String mm) {
        if (StringUtils.isEmpty(mm)) {
            return null;
        }
        BigDecimal thousand = new BigDecimal("1000");

        BigDecimal Mm = new BigDecimal(mm);
        if (Mm.compareTo(thousand) == -1) { //距离小于1KM
            Mm = Mm.setScale(1, BigDecimal.ROUND_HALF_UP);
            return Mm.intValue() + "m";
        } else { //距离大于等于1KM
            Mm = Mm.divide(thousand).setScale(1, BigDecimal.ROUND_HALF_UP);
            return Mm + "km";
        }
    }

    public static StoreBaseBizDto toStoreBaseBizDto(StoreDto beanDto) {
        StoreBaseBizDto beanBizDto = null;
        if (beanDto != null) {
            beanBizDto = new StoreBaseBizDto();
            BeanUtils.copyProperties(beanDto, beanBizDto);
            beanBizDto.setStatus(beanDto.getStatus());
            beanBizDto.setStatusModifyType(beanDto.getStatusModifyType());
            beanBizDto.setVerifyStatus(beanDto.getVerifyStatus());
        }
        return beanBizDto;
    }

    /*********************************门店转换结束*************************************************/


    /*********************************设备转换结束*************************************************/
    public static List<DeviceDto> toDeviceDtoList(List<DeviceBean> beanList) {
        List<DeviceDto> dtoList = new ArrayList<>();
        if (beanList != null && beanList.size() > 0) {
            for (DeviceBean bean : beanList) {
                dtoList.add(toDeviceDto(bean));
            }
        }
        return dtoList;
    }

    public static DeviceDto toDeviceDto(DeviceBean bean) {
        DeviceDto beanDto = null;
        if (bean != null) {
            beanDto = new DeviceDto();
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setDeviceId(bean.getId());
        }
        return beanDto;
    }

    public static DeviceBean toDeviceBean(DeviceCreateDto bean) {
        DeviceBean beanDto = null;
        if (bean != null) {
            beanDto = new DeviceBean();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static DeviceBean toDeviceBean(DeviceModifyDto bean) {
        DeviceBean beanDto = new DeviceBean();
        if (bean != null) {
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static List<StoreDeviceDto> toStoreDeviceDtoList(List<StoreDeviceBean> beanList) {
        List<StoreDeviceDto> dtoList = new ArrayList<>();
        if (beanList != null && beanList.size() > 0) {
            for (StoreDeviceBean bean : beanList) {
                dtoList.add(toStoreDeviceDto(bean));
            }
        }
        return dtoList;
    }

    public static StoreDeviceDto toStoreDeviceDto(StoreDeviceBean bean) {
        StoreDeviceDto beanDto = new StoreDeviceDto();
        if (bean != null) {
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static List<DeviceInfoBizDto> toDeviceInfoBizDtoLIst(List<DeviceDto> beanList) {
        List<DeviceInfoBizDto> dtoList = new ArrayList<>();
        if (beanList != null && beanList.size() > 0) {
            for (DeviceDto bean : beanList) {
                dtoList.add(toDeviceInfoBizDto(bean));
            }
        }
        return dtoList;
    }

    public static DeviceInfoBizDto toDeviceInfoBizDto(DeviceDto deviceDto) {
        DeviceInfoBizDto deviceInfoBizDto = new DeviceInfoBizDto();
        if (deviceDto != null) {
            BeanUtils.copyProperties(deviceDto, deviceInfoBizDto);

        }
        return deviceInfoBizDto;
    }

    public static DeviceParamDictDto toDeviceParamDictDto(DeviceParamDictBean bean) {
        DeviceParamDictDto beanDto = new DeviceParamDictDto();
        if (bean != null) {
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setParamDictId(bean.getId());
        }
        return beanDto;
    }

    /*********************************设备转换结束*************************************************/

    public static DeviceUnionpayParamDto toDeviceUnionpayParamDto(DeviceUnionpayParamBean bean) {
        DeviceUnionpayParamDto beanDto = null;
        if (bean != null) {
            beanDto = new DeviceUnionpayParamDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static List<FenceStoreStockDto> toFenceStoreStockDtoList(List<FenceStoreStockBean> beanList) {
        List<FenceStoreStockDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (FenceStoreStockBean bean : beanList) {
                dtoList.add(toFenceStoreStockDto(bean));
            }
        }
        return dtoList;
    }

    public static FenceStoreStockDto toFenceStoreStockDto(FenceStoreStockBean bean) {
        FenceStoreStockDto beanDto = null;
        if (bean != null) {
            beanDto = new FenceStoreStockDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static StoreDeviceBean toStoreDeviceBean(StoreDeviceBizModifyDto dto) {
        StoreDeviceBean bean = new StoreDeviceBean();
        if (dto != null) {
            BeanUtils.copyProperties(dto, bean);
        }
        return bean;
    }

}
